<?php
class Bliss_Rcon_Game_BadCompany2 extends Bliss_Rcon_Game_Abstract
{
	protected $sequence = 1;
	protected $protocolName = 'Frostbite';

	protected function init()
	{}

	public function exec($command, array $args=null)
	{
		fwrite($this->socket, $this->protocol->encode($command, $args));
		list($isFromServer, $isResponse, $sequence, $words) = $this->protocol->decode(fread($this->socket, 4096));
		return $words;
	}

	public function login()
	{
		$result = $this->exec("login.plainText", array($this->password));
		$error = null;
		if(!isset($result[0])) {
			$error = "Could not login to server, unknown reason.";
		} elseif($result[0] != 'OK') {
			switch($result[0]) {
				case 'InvalidPassword':
					$error = "Invalid password provided for server login.";
					break;
				default:
					$error = "Could not login to server, unknown reason.";
					break;
			}
		}

		if(isset($error)) {
			throw new Bliss_Rcon_Exception($error);
		}
	}
}
?>